Schema Directives (graphql)
フィールドやスキーマにメタ情報を付与する仕組み
GraphQL標準のdirective
@skip(if: Boolean!)
条件が true のときそのフィールドをスキップ
@include(if: Boolean!)
条件が true のときそのフィールドを含める
@deprecated(reason: String)
フィールド・enum値が非推奨であることを示す
@specifiedBy(url: String!)
カスタムスカラー型の仕様URLを示す
例
code:graphql(js)
directive @deprecated(
reason: String = "No longer supported"
) on FIELD_DEFINITION | ENUM_VALUE
type ExampleType {
newField: String
oldField: String @deprecated(reason: "Use newField.")
}